package conf

import (
	"github.com/spf13/viper"
	"go.uber.org/zap"
)

// VarsSection map toml [vars]
type VarsSection struct {
	AccountSecret       string `mapstructure:"account_secret"`
	HTTPTimeout         uint8  `mapstructure:"http_timeout"`
	GrpcTimeout         uint8  `mapstructure:"grpc_timeout"`
	BilinPubKey         string `mapstructure:"bilin_pub_key"`
	AuthorizationPubKey string `mapstructure:"authorization_pub_key"`
}

// ReadVars get vars section from config
func ReadVars(v *viper.Viper, slog *zap.SugaredLogger) (varsConf VarsSection) {
	err := v.Unmarshal(&varsConf)
	if err != nil {
		slog.Panicf("unable to decode into wxpay section, %v", err)
	}
	return
}
